package hczc.longcai.com.hccrowdfunding.home.third_rankinglist.adapters;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import java.util.List;

import hczc.longcai.com.hccrowdfunding.R;
import hczc.longcai.com.hccrowdfunding.application.BaseApplication;
import hczc.longcai.com.hccrowdfunding.home.second_invest.activities.PayActivity;
import hczc.longcai.com.hccrowdfunding.home.third_rankinglist.beans.RankingListPopularity;

/**
 * Created by Administrator on 2016/1/21.
 */
public class RankingListAdapter extends BaseAdapter {

    private Context context;
    private List<RankingListPopularity> list;

    public RankingListAdapter(Context context, List<RankingListPopularity> list) {
        this.context = context;
        this.list = list;
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int i) {
        return list.get(i);
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public int getItemViewType(int position) {
        return list.get(position).getType();
    }

    @Override
    public int getViewTypeCount() {
        return 3;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        ViewHolder holder = null;
        int type = list.get(i).getType();
        if (view == null) {
            holder = new ViewHolder();
            switch (type) {
                case 1:
                    view = LayoutInflater.from(context).inflate(R.layout.item_rankinglist_popular, null);
                    BaseApplication.scaleScreenHelper.loadView(((ViewGroup) view));
                    view.setTag(holder);

                    break;
                case 2:
                    view = LayoutInflater.from(context).inflate(R.layout.item_rankinglist_normal,null);
                    BaseApplication.scaleScreenHelper.loadView(((ViewGroup) view));
                    view.setTag(holder);
                    break;


            }

        }
        holder = ((ViewHolder) view.getTag());


        return view;
    }

    class ViewHolder {
        TextView title, numberPeople, completePercent;
        ImageView ranking, head;

    }
}
